<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.serviceno" placeholder="业务件号" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="dataForm.realtyno" placeholder="不动产登记证明号" clearable></el-input>
      </el-form-item>
      <el-form-item>
              <el-select
                    v-model="dataForm.orgid"
                    clearable
                    filterable
                    style="width:300px;"
                    remote
                
                    placeholder="输入抵押权人代码或名称"
                    :remote-method="remoteMethod"
                    :loading="loading">
                    <el-option
                      v-for="item in list"
                      :key="item.branchid"
                      :label="item.branchname"
                      :value="item.branchid">
                    </el-option>
                  </el-select>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="dataForm.begindate"
          type="datetime"
          placeholder="选择起始时间"
          align="right"
          default-time="00:00:00"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>   

      <el-form-item>
        <el-date-picker
          v-model="dataForm.enddate"
          type="datetime"
          placeholder="选择结束时间"
          default-time="23:59:59"
          align="right"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>    
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>

      </el-form-item>
    </el-form>

    <el-table
      v-if="dataList.length == 0"
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">

      <el-table-column
        prop="recvtime"
        header-align="center"
        align="center"
        label="接收时间">
      </el-table-column>
      <el-table-column
        prop="bdcno"
        header-align="center"
        align="center"
        label="登记中心">
      </el-table-column>
      <el-table-column
        prop="obankname"
        header-align="center"
        align="center"
        label="抵押权人名称">
      </el-table-column>

      <el-table-column
        prop="regionTranslate"
        header-align="center"
        align="center"
        label="区域">
      </el-table-column>

      <el-table-column
        prop="serviceno"
        header-align="center"
        align="center"
        label="业务件号">
      </el-table-column>

      <el-table-column
        prop="realtyno"
        header-align="center"
        align="center"
        label="登记证明号">
      </el-table-column>




      <el-table-column
        fixed="left"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small"  v-if="isAuth('bdc:bdcrealtyinfo:save')"  
          @click="dyQueryHandle(scope.row.seRegion, scope.row.region, scope.row.serviceno, scope.row.realtyno, scope.row.obankid)">
            抵押查询</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-table
      v-if="dataList.length > 0"
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">

      <el-table-column
        prop="recvtime"
        header-align="center"
        align="center"
        width="160px"
        label="接收时间">
      </el-table-column>
      <el-table-column
        prop="bdcno"
        header-align="center"
        align="center"
          width="280px"
        label="登记中心">
      </el-table-column>
      <el-table-column
        prop="obankname"
        header-align="center"
        align="center"
            width="360px"
        label="抵押权人名称">
      </el-table-column>

      <el-table-column
        prop="regionTranslate"
        header-align="center"
        align="center"
        label="区域">
      </el-table-column>

      <el-table-column
        prop="serviceno"
        header-align="center"
        align="center"
            width="180px"
        label="业务件号">
      </el-table-column>

      <el-table-column
        prop="realtyno"
        header-align="center"
        align="center"
         width="180px"
        label="登记证明号">
      </el-table-column>




      <el-table-column
        fixed="left"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small"  v-if="isAuth('bdc:bdcrealtyinfo:save')"  
          @click="dyQueryHandle(scope.row.seRegion, scope.row.region, scope.row.serviceno, scope.row.realtyno, scope.row.obankid)">
            抵押查询</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="datepicker.pageOptions"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <bdc-dy-query v-if="dyQueryVisible" ref="dyQuery" ></bdc-dy-query>  
    
  </div>
</template>

<script>
  import BdcDyQuery from './bdc-dy-query'
  export default {
    data () {
      return {
        pickerOptions: this.datepicker.pickerOptions,

        dataForm: {
          orgid: '',
          realtyno: '',
          serviceno: '',
          begindate: '',
          enddate: ''
        },
        loading: false,
        dataList: [],
        list: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        dyQueryVisible: false
      }
    },
    components: {
      BdcDyQuery
    },
    activated () {
      this.getDataList()
    },
    methods: {

      remoteMethod(query) {
        if (query !== '') {
          this.loading = true;

          this.$http({
            url: this.$http.adornUrl(`/sys/user/branch/search`),
            method: 'get',
            params: this.$http.adornParams({
              "key": query
            })
          }).then(({data}) => {
            this.loading = false;
            if (data && data.code === 0) {
                this.list = data.list;
            }
          })     
          
        } else {
          this.list = [];
        }
      },

      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/bdc/bdcpushmessage/zcbdy/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'realtyno': this.dataForm.realtyno,
            'orgid': this.dataForm.orgid,
             'serviceno': this.dataForm.serviceno,
            'begindate': this.dataForm.begindate,
            'enddate': this.dataForm.enddate
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      dyQueryHandle (seRegion, region, serviceno, realtyno, obankid) {
        this.dyQueryVisible = true
        this.$nextTick(() => {
          this.$refs.dyQuery.init(1, seRegion, region, serviceno, realtyno, obankid)
        })
      }


      
    }
  }
</script>
<style lang="scss">
body .el-table th.gutter{
    display: table-cell!important;

}
</style>